<?php
require_once('controller/auth.php');
//Start session
@session_start();

//Include database connection details
require_once('controller/inc/config.inc');

//Array to store validation errors
$errmsg_arr = array();

//Validation error flag
$errflag = false;

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<title>Project Tracking MIS</title>

<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!-- Le styles -->
<link rel="stylesheet" href="assets/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="assets/css/bootstrap-responsive.css"
	type="text/css" />
<link rel="stylesheet" href="assets/css/font-awesome.css"
	type="text/css" />
	<link rel='stylesheet' href='assets/css/datepicker.css'>
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
<script type="text/javascript" src='assets/js/bootstrap-datepicker.js'></script>
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-popover.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-tooltip.js"></script>
<script>
$(function ()
{ 
$("input").popover({trigger: 'focus', 'placement':'right'});

$("textarea").popover({trigger: 'focus'});


$('#tab').tooltip({'placement':'right', 'trigger' : 'hover'});

$('a').tooltip({'placement':'bottom', 'trigger' : 'hover'});	
});
</script>

<style>
body {
	padding-top: 60px;
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}

.dropdown-menu .sub-menu {
	left: 100%;
	position: absolute;
	top: 0;
	visibility: hidden;
	margin-top: -1px;
}

.dropdown-menu li:hover .sub-menu {
	visibility: visible;
	display: block;
}

.navbar .sub-menu:before {
	border-bottom: 7px solid transparent;
	border-left: none;
	border-right: 7px solid rgba(0, 0, 0, 0.2);
	border-top: 7px solid transparent;
	left: -7px;
	top: 10px;
}

.navbar .sub-menu:after {
	border-top: 6px solid transparent;
	border-left: none;
	border-right: 6px solid #fff;
	border-bottom: 6px solid transparent;
	left: 10px;
	top: 11px;
	left: -6px;
}
div.btn-group[data-toggle=buttons-radio] input[type=radio] {
  display:    block;
  position:   absolute;
  top:        0;
  left:       0;
  width:      100%;
  height:     100%;
  opacity:    hidden;
  visibility: hidden;
}


</style>
<!-- Le fav and touch icons -->

</head>

<body>
<div class="container-fluid"><!--TOp Nav-->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid"><a data-target=".nav-collapse"
	data-toggle="collapse" class="btn btn-navbar"> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a
	href="#" class="brand">TMIS | Project Tracking</a>
<div class="nav-collapse">
<ul class="nav">
	<li><a href="dashboard.php">Home Page</a></li>
	<li><a href="create_project.php">Create Project</a></li>
	<li class='active'><a href="update_project.php">Update Project</a></li>
	<li><a href="reports.php">Reports</a></li>

</ul>
<form action="" class="navbar-search pull-left">
<input type="text" placeholder="Search" class="search-query span2">

</form>
<ul class="nav pull-right">


	<div class="pull-right">
	<ul class="nav pull-right">
		<li class="dropdown"><a href="#" class="dropdown-toggle"
			data-toggle="dropdown">Welcome, <?php echo $_SESSION['SESS_FIRST_NAME'] . " " . $_SESSION['SESS_LAST_NAME'];?>
		<b class="caret"></b></a>
		<ul class="dropdown-menu">
			<li><a href="/user/preferences"><i class="icon-cog"></i> Preferences</a></li>
			<li><a href="/help/support"><i class="icon-envelope"></i> Contact
			Support</a></li>
			<li class="divider"></li>
			<li><a href="controller/logout.php"><i class="icon-off"></i> Logout</a></li>
		</ul>
		</li>
	</ul>
	</div>


</ul>
</div>
<!-- /.nav-collapse --></div>
</div>
</div>


<script>
$(document).ready(function()
{
  //Handles menu drop down
  $('.dropdown-menu').find('form').click(function (e) {
        e.stopPropagation();
        });

  $('#myTab a').click(function (e) {
	  e.preventDefault();
	  $(this).tab('show');
	});

  
  
  });
</script>

 <script type="text/javascript">
$(function() {
	//call the function onload
	getdata( 1 );
});

function getdata( pageno ){                     
	var targetURL = 'pagination/search_results.php?page=' + pageno;   

	$('#retrieved-data').html('<p><img src="pagination/ajax-loader.gif" /></p>');        
	$('#retrieved-data').load( targetURL ).hide().fadeIn('slow');
}      
</script> <!--/Top Nav-->
<div class="row-fluid">

<div class="span12"><!--Content--> <?php 
$serial=$_GET['id'];
$select_proj=mysql_query("SELECT * FROM main WHERE serial='$serial'");
$row_proj=mysql_fetch_array($select_proj);
$status=$row_proj['status'];
	$progress=0;
	switch($status){
	case 0:
	$status='Initiated';
	$progress="<div class='bar' style='width: 10%;' rel='tooltip' title='The overall progress of project is 10%!' data-placement='top'></div>";
	break;
	case 1:
	$status='Approved by MoE';
	$progress="<div class='bar' style='width: 30%;' rel='tooltip' title='The overall progress of project is 30%!' data-placement='top'></div>";
	break;
	case 2:
	$status='Budget Allocated';
	$progress="<div class='bar' style='width: 50%;' rel='tooltip' title='The overall progress of project is 50%!' data-placement='top'></div>";
	break;
	
	case 3:
	$status='Allotment Received';
	$progress="<div class='bar' style='width: 80%;' rel='tooltip' title='The overall progress of project is 80%!' data-placement='top'></div>";
	break;
	
	case 4:
	$status='Done';
	$progress="<div class='bar bar-success' style='width: 100%;' rel='tooltip' title='Good Job, the overall progress of project is 100%!' data-placement='top'></div>";
	break;
	
	default:
	$status='Undefined!';
	}
?>
<h2 class='text-info'>Update: <span class='muted'><?php echo $row_proj['proj_name']; ?></span></h2>
<div><a href='javascript:history.back()' class='btn'>Back to Main List</a></div>

<br />


<ul class="nav nav-tabs" id="myTab">
	
  <li class="active"><a href="#iniated" data-toggle="tab">Project Initiation</a></li>
  <li class='disabled'><a href="#approved" data-toggle="tab">Approved by MoE</a></li>
  <li><a href="#budget_allocated" data-toggle="tab">Budget Allocated</a></li>
  <li><a href="#allotment" data-toggle="tab">Allotment Received</a></li>
  
</ul>
 <div id='updateResult'></div>
<div class="tab-content">
  <!-- First Tab -->
<script type='text/javascript' src='ajax/update1.js'></script>
  <div class="tab-pane active" id="iniated">
  <h3>Update Project Initiation</h3>
  <div class="form-horizontal">
  <fieldset>
   
    <div class="control-group">
      <!-- Username -->
      <label class="control-label">Project Name</label>
      <div class="controls">
        <input type="text" id='pname' name="pname" placeholder="" class="input-xlarge" value='<?php echo $row_proj['proj_name']; ?>'>
        <p class="help-block">Enter a short name for your project</p>
      </div>
    </div>

    <div class="control-group">
      <!-- E-mail -->
      <label class="control-label">Project Request Number</label>
      <div class="controls">
        <input type="text" id='prnumber' name="prnumber" placeholder="" class="input-xlarge" value='<?php echo $row_proj['request_no'];?>'>
        <p class="help-block">Please provide Project Number (e.g 1342)</p>
      </div>
    </div>

    <div class="control-group">
      <!-- Password-->
      <label class="control-label">Amount</label>
      <div class="controls">
        <input type="text" id='amount' name="amount" placeholder="" class="input-xlarge" value='<?php echo $row_proj['amount'];?>'>
        <p class="help-block">Project Amount in USD or AF (e.g. $1,200 or AF 50,000)</p>
      </div>
    </div>
    <div class="control-group">
      <!-- Password-->
      <label class="control-label">Physical File Location</label>
      <div class="controls">
        <input type="text" id='flocation' name="flocation"  class="input-xlarge" value='<?php echo $row_proj['file_location']; ?>'>
        <p class="help-block">Relevant file location for this project(e.g. Salary Folder)</p>
      </div>
    </div>
     <div class="control-group">
      <!-- Password-->
      <label class="control-label">Expected TED Approval</label>
      <div class="controls">
        <input type="text" id='est_ted'  placeholder='Number of Days' class="input-xlarge" value='<?php echo $row_proj['est_day_ted'];?>'>
        <p class="help-block">Number of estimated days for getting TED Approval.</p>
      </div>
    </div>
     <script>
		$(function(){
			$('#tab1_date_01').datepicker({ todayBtn:'linked'});
			});
		</script>
       <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">TED Approval Date:</label>
		      <div class="controls">
		        <div class="input-append date"  id="tab1_date_01" data-date="" data-date-format="yyyy-mm-dd" class="input-xlarge">
				    <input type="text" disabled="disabled" id="app_ted" value='<?php echo $row_proj['aprrove_ted_date']; ?>'/>
				    <span class="add-on"><i class="icon-calendar"></i></span>
				</div> 
		        <p class="help-block">When did TED approved project document?</p>
		      </div>
		    </div> 
		    
    
    <div class="controls-group">
    <label class="control-label">Project Description</label>
      <div class="controls">
          <textarea id="desc" name="desc" class="span6" placeholder="Project Description" rows="5"><?php echo $row_proj['description']?></textarea>
      </div>
    </div>
    
    <input type='hidden' value ='<?php echo $row_proj['serial']; ?>' id='serial'>
    <input type='hidden' value ='<?php echo $row_proj['status']; ?>' id='status'>
    <div class="clearfix"></div><br>
    <div class="control-group">
      <!-- Button -->
      <div class="controls">
        <button class="btn btn-primary" id='subbtn'>Update Project</button>
      </div>
    </div>
  </fieldset>
</div>
  
  </div>
   <!-- /First Tab -->
  
   <!-- Second Tab -->
  
  <div class="tab-pane" id="approved">
  <h3>Approval of Ministry of Education</h3>
 <br />
		 <script>
		$(function(){
			$('#sub_to_moe').datepicker({ todayBtn:'linked'});
			$('#app_moe').datepicker({ todayBtn:'linked'});
			});
		</script>
		<script type='text/javascript' src="ajax/update2.js"></script>
		<!-- Form Div -->
		<div class="form-horizontal">
		  <fieldset>
		    
		    
		     <div class="control-group">
		      <!-- Username -->
		      <label class="control-label" >Submission Date to MoE:</label>
		      <div class="controls">
		        <div class="input-append date" id="sub_to_moe" data-date="" data-date-format="yyyy-mm-dd" class="input-xlarge" >
				    <input type="text" id="sub_to_moe_txt" disabled="disabled" value="<?php echo $row_proj['submission_moe_date']; ?>" />
				    <span class="add-on"><i class="icon-calendar"></i></span>
				</div> 
		        <p class="help-block">When you have submitted this project documents to Ministry of Education?</p>
		      </div>
		    </div> 
		    
		    <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">Estimated Days:</label>
		      <div class="controls">
		        <input type="text" id="moe_est_days" placeholder="An Integer Value (e.g. 5)" class="input-xlarge" value="<?php echo $row_proj['est_day_moe']; ?>">
		        <p class="help-block">In how many days you expects to receive the MoE Approval?</p>
		      </div>
		    </div>
		    
		      <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">MoE Approval Date:</label>
		      <div class="controls">
		        <div class="input-append date" id="app_moe" data-date="" data-date-format="yyyy-mm-dd" class="input-xlarge">
				    <input type="text" id="moe_app" disabled="disabled" value="<?php echo $row_proj['approve_moe_date']; ?>" />
				    <span class="add-on"><i class="icon-calendar"></i></span>
				</div> 
		        <p class="help-block">When Ministry of Education has approved your document?</p>
		      </div>
		    </div> 
		    <input type="hidden" id='status2' value='<?php echo $row_proj['status']; ?>'/>
		    <input type="hidden" id='sn2' value='<?php echo $row_proj['serial']; ?>'/>
		    <div class="control-group">
		      <!-- Button -->
		      <div class="controls">
		        <button class="btn btn-primary" id="sub_btn_02"><i class='icon-save'></i>&nbsp;Save</button>
		      </div>
		    </div>
		    
		    </fieldset>
		    </div>
		    <!-- /Form Div -->
 
  
  </div>
  
   <!-- /Second Tab -->
   
    <!-- Third Tab -->
  <div class="tab-pane" id="budget_allocated"><h3>Budget Allocation by Finance Department of MoE</h3>
   <br />
		 <script>
		$(function(){
			$('#tab3_date_01').datepicker({ todayBtn:'linked'});
			$('#tab3_date_02').datepicker({ todayBtn:'linked'});
			});
		</script>
		<script type='text/javascript' src="ajax/update3.js"></script>
		<!-- Form Div -->
		<div class="form-horizontal">
		  <fieldset>
		    
		     <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">Submission Date to MoE Finance:</label>
		      <div class="controls">
		        <div class="input-append date"  id="tab3_date_01" data-date="" data-date-format="yyyy-mm-dd" class="input-xlarge">
				    <input type="text" id="sub_to_moe_f" disabled="disabled" value='<?php echo $row_proj['submission_moe_finance_date']; ?>' />
				    <span class="add-on"><i class="icon-calendar"></i></span>
				</div> 
		        <p class="help-block">When you have submitted this project documents to Ministry of Education Finance Dept?</p>
		      </div>
		    </div> 
		    
		    <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">Estimated Days:</label>
		      <div class="controls">
		        <input type="text" id="est_days_moe_f" name="est_days_moe_f" placeholder="An Integer Value (e.g. 5)" class="input-xlarge" value='<?php echo $row_proj['est_day_moe_fn']; ?>'>
		        <p class="help-block">In how many days you expects to receive the MoE Finance Dept Approval?</p>
		      </div>
		    </div>
		    
		      <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">MoE Finance Approval Date:</label>
		      <div class="controls">
		        <div class="input-append date"  id="tab3_date_02" data-date="" data-date-format="yyyy-mm-dd" class="input-xlarge">
				    <input type="text" disabled="disabled" id="app_moe_f" value='<?php echo $row_proj['received_moe_finace_date']; ?>'/>
				    <span class="add-on"><i class="icon-calendar"></i></span>
				</div> 
		        <p class="help-block">When did Finance Department of Ministry of Education has approved your document?</p>
		      </div>
		    </div> 
		   
		     <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">Accepted or Rejected:</label>
		      <div class="controls">
		        <div class="btn-group" data-toggle="buttons-radio" >
			  <button type="button" class="btn btn-warning btn-small" data-toggle="button">
			    <i class='icon-ok'></i>&nbsp;Accepted
			    <input type="radio" name="accrej" value="Accepted" />
			  </button>
			  <button type="button" class="btn btn-warning btn-small" data-toggle="button">
			    <i class='icon-remove'></i>&nbsp;Rejected
			    <input type="radio" name="accrej" value="Rejected" />
			  </button>
			</div>
		      </div>
		    </div>
		    
		    
		    <input type="hidden" id='status3' value='<?php echo $row_proj['status']; ?>'/>
		    <input type="hidden" id='sn3' value='<?php echo $row_proj['serial']; ?>'/>
		    <div class="control-group">
		      <!-- Button -->
		      <div class="controls">
		        <button class="btn btn-primary" id='sub_btn_03'><i class='icon-save'></i>&nbsp;Save</button>
		      </div>
		    </div>
		   
		   
		    
		   
		    </fieldset>
		    </div>
		    <!-- /Form Div -->
  
  
  </div>
   <!-- /Third Tab -->
   
    <!-- Fourth Tab -->
  <div class="tab-pane" id="allotment"><h3>Allotment Received from MoF</h3>
  <script type='text/javascript' src='ajax/update4.js'></script>
  <br />
		 <script>
		$(function(){
			$('#sub_to_moe_allot').datepicker({ todayBtn:'linked'});
			$('#app_moe_allot').datepicker({ todayBtn:'linked'});
			});
		</script>
		
		<!-- Form Div -->
		<div class="form-horizontal">
		  <fieldset>
		    
		    
		     <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">Submission Date to MoF:</label>
		      <div class="controls">
		        <div class="input-append date" id="sub_to_moe_allot" data-date="" data-date-format="yyyy-mm-dd" class="input-xlarge">
				    <input type="text" id="psub_to_moe_allot" value="<?php echo $row_proj['submission_mof_date'];?>" disabled="disabled" />
				    <span class="add-on"><i class="icon-calendar"></i></span>
				</div> 
		        <p class="help-block">When you have submitted this project documents to Ministry of Finance for Allotment?</p>
		      </div>
		    </div> 
		    
		    <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">Estimated Days:</label>
		      <div class="controls">
		        <input type="text" value = "<?php echo $row_proj['est_day_mof'];?>" id="est_days_allot" placeholder="An Integer Value (e.g. 5)" class="input-xlarge">
		        <p class="help-block">In how many days you expects to receive Allotment from MoF?</p>
		      </div>
		    </div>
		    
		      <div class="control-group">
		      <!-- Username -->
		      <label class="control-label">Allotment Received Date:</label>
		      <div class="controls">
		        <div class="input-append date" id="app_moe_allot" data-date="" data-date-format="yyyy-mm-dd" class="input-xlarge">
				    <input type="text" id="papp_moe_allot"  disabled="disabled"  value="<?php echo $row_proj['cheque_issue_date'];?>" />
				   
				    <span class="add-on"><i class="icon-calendar"></i></span>
				</div> 
		        <p class="help-block">When TED received allotment from MoF?</p>
		      </div>
		    </div> 
		    
		    <input type="hidden" id='sn4' value='<?php echo $row_proj['serial']; ?>'/>
		    <div class="control-group">
		      <!-- Button -->
		      <div class="controls">
		         <button class="btn btn-primary" id="sub_btn_04"><i class='icon-save'></i>&nbsp;Save</button>
		      </div>
		    </div>
		    
		    </fieldset>
		    </div>
		    <!-- /Form Div -->
  
  
  </div>
 <!-- /Fourth Tab  -->

</div>
 <!-- End  Tab Content -->



<!--/Content--></div>



</div>
<hr />
<footer class="footer"> &copy;2013 TMIS, TED, MoE </footer></div>

</body>

</html>
